package main

import (
	"common-admin/config"
	"common-admin/controller"
	"common-admin/logger"
	"common-admin/route"
	"fmt"
	"github.com/gin-gonic/gin"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

func main() {
	r := gin.Default()
	//配置文件路径
	confFile := "E:/WWW/conf.yml"
	//加载配置
	conf, err := config.InitConfig(confFile)
	if err != nil {
		fmt.Printf("初始化项目配置失败，错误信息：%v\n", err)
		panic("服务启动失败")
	}
	fmt.Printf("%+v\n", conf)
	r.GET("/order/:id", controller.Show)
	//加载路由
	route.LoadRoute(r)
	address := fmt.Sprintf("%s:%s", conf.Data.App.Host, conf.Data.App.Port)
	logger.Info("app starting.........")
	r.Run(address)
}
